const App = {
    mixins: [Save],//配置文件，路径/utils/mixins.js
    data() {
        return {
            photo,
            Project_CategoryInfo:[],
            city:[],
            CompletionInfo:[{value:'0',label:'未竣工'},{value:'1',label:'已竣工'}],
            showDialog: false,
            childDataForm:[],
            fileUrl:''
        };
    },
    mounted() {
        this.init()

    },
    watch: {



    },
    methods: {
        preview(row) {
            this.fileUrl = photo + row.Attachment_Name;
            this.showDialog = true;
        },
        async download(row) {
            // if (row.Attachment_Name) {
            //     window.location.href = photo + row.Attachment_Name;
            // }
            let apiUrl = photo + row.Attachment_Name;
            let fileName = apiUrl.split('/').pop();
            try {
                const response = await fetch(apiUrl);
                const blob = await response.blob();
                const url = window.URL.createObjectURL(blob);

                const a = document.createElement('a');
                a.href = url;
                a.download = fileName || 'download';
                document.body.appendChild(a);
                a.click();

                // 清理
                setTimeout(() => {
                    document.body.removeChild(a);
                    window.URL.revokeObjectURL(url);
                }, 100);
            } catch (error) {
                console.error('下载失败:', error);
            }
        },
        init() {
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: "POST",
                data: {
                    Data: 'Village_Project_Category',
                    Condition: "Row_Status='0' ",
                },
                success: (data) => {
                    this.Project_CategoryInfo = data;
                    
                },
                complete: (XMLHttpRequest) => {

                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });

            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/permissionsTree/getDistrictTreeByPermissions`,
                type: "GET",
                data: {
                    DistrictCode: getCookie('village'),

                },
                success: (data) => {
                    this.city = data; // 直接使用 this
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });

        },

        





    },

};
const { createApp, ref } = Vue;
const app = createApp(App);
app.use(ElementPlus, { locale: zhCn });
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
app.component('yl-upload', ylUpload);
app.component('yl-select', ylSelect);
app.component('yl-text-editor', ylTextEditor);
app.component('yl-online-preview', ylOnlinePreview);
const ElMessage = ElementPlus.ElMessage;
app.mount("#app");
